/**
 *	VisualGroup JavaScript prototype Classes, version 0.1
 *  (c) 2008 Bill Vison <vison_ruan@126.com>
 *
 *
/*--------------------------------------------------------------------------*/
using("Vsg.FlashHttpRequest");
Vsg.TreeLoader = Ext.extend(Ext.tree.TreeLoader,{
						  
	requestData : function(node, callback){

        if(this.fireEvent("beforeload", this, node, callback) !== false){
			
			
		// load config object 
		var $actionConfig = {};
		$actionConfig.url = this.dataUrl||this.url;
		
		$actionConfig.scope = this;

		$actionConfig.method = "POST";
		$actionConfig.timeout = 30;
		
		$actionConfig.params = {};
		if (node != null) {
			$actionConfig.params.node = node.id;
		}
		if (this.baseParams != null) {
			for (var $i in this.baseParams) {
				$actionConfig.params[$i] = this.baseParams[$i];
			}
		}
		

		$actionConfig.success = function($response , $options) {
			this.transId = false;
        	this.processResponse($response, node, callback);
        	this.fireEvent("load", this, node, response);			
		}
		$actionConfig.failure = function($response , $options) {
        	this.transId = false;
        	this.fireEvent("loadexception", this, node, $response);
        	if(typeof callback == "function"){
            	callback(this, node);
        	}
		}
		
		Vsg.FlashHttpRequest.request($actionConfig);			
			/*
            this.transId = Ext.Ajax.request({
                method:this.requestMethod,
                url: this.dataUrl||this.url,
                success: this.handleResponse,
                failure: this.handleFailure,
                scope: this,
                argument: {callback: callback, node: node},
                params: this.getParams(node)
            });
			*/

        }else{
            
            
            if(typeof callback == "function"){
                callback();
            }
        }
		
	}
});